<template>
	<baseDialog ref="dialogRef" :title="dialogTitle" width="680px" :showFooter="false" @close="handleClose">
		<el-descriptions class="w-full" direction="horizontal" :column="1" border>
			<el-descriptions-item class-name="el-descriptions-content-break" label-class-name="w-[130px]" label="名称">
				{{ detailData.name }}
			</el-descriptions-item>
			<el-descriptions-item class-name="el-descriptions-content-break" label-class-name="w-[130px]" label="命令">
				{{ detailData.command }}
			</el-descriptions-item>
			<el-descriptions-item class-name="el-descriptions-content-break" label-class-name="w-[130px]" label="运行规则">
				{{ detailData.expression_desc }}
			</el-descriptions-item>
			<el-descriptions-item class-name="el-descriptions-content-break" label-class-name="w-[130px]" label="参数">
				{{ detailData.params }}
			</el-descriptions-item>
			<el-descriptions-item class-name="el-descriptions-content-break" label-class-name="w-[130px]" label="状态">
				{{ detailData.status_desc }}
			</el-descriptions-item>
			<el-descriptions-item class-name="el-descriptions-content-break" label-class-name="w-[130px]" label="运行失败错误">
				{{ detailData.error }}
			</el-descriptions-item>
			<el-descriptions-item class-name="el-descriptions-content-break" label-class-name="w-[130px]" label="执行时长">
				{{ detailData.exe_time }} 秒
			</el-descriptions-item>
			<el-descriptions-item class-name="el-descriptions-content-break" label-class-name="w-[130px]" label="最大执行时长">
				{{ detailData.max_time }} 秒
			</el-descriptions-item>
			<el-descriptions-item class-name="el-descriptions-content-break" label-class-name="w-[130px]" label="最后执行时间">
				{{ detailData.last_time }}
			</el-descriptions-item>
			<el-descriptions-item class-name="el-descriptions-content-break" label-class-name="w-[130px]" label="备注">
				{{ detailData.remark }}
			</el-descriptions-item>
			<el-descriptions-item class-name="el-descriptions-content-break" label-class-name="w-[130px]" label="创建时间">
				{{ detailData.create_time }}
			</el-descriptions-item>
		</el-descriptions>
	</baseDialog>
</template>

<script setup lang="ts" name="crontabDetail">
import { ref, computed } from 'vue';
import { crontabDetail } from '/@/api/setting/crontab';

const dialogRef = ref(null);

const dialogTitle = computed(() => {
	return '定时任务详情';
});

const emit = defineEmits(['close']);

const detailData = ref(null);

const setFormData = async (row: any, callback: any) => {
	const data = await crontabDetail({
		id: row.id,
	});

	detailData.value = data;

	callback();
};

const handleClose = () => {
	emit('close');
};

const open = () => {
	dialogRef.value?.open();
};

defineExpose({
	open,
	setFormData,
});
</script>
